{template header}
<style type="text/css">
  li { margin-right: 10px; }
</style>
<script src="static/bootstrap/js/utils.js"></script>
<script src="static/bootstrap/js/amap.area.js"></script>
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script language="javascript" src="http://webapi.amap.com/maps?v=1.3&key=1f47cfba244d5d93a9e615ee660d1284"></script>
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<script type="text/javascript">
  window.onload=function (){
    mapInit();
  }
  $(document).ready(function(){
      $("#expressionUl>li>img").click(function()
        {
          selectedNum = $(this).attr("dataSrc");
          $("#expressionId").val(selectedNum);
          $("#expressionUl>li>img").each(function(){
            num = $(this).attr("dataSrc");
            newSrc = "static/backend/run_mood/feeling_"+num+'_' + (num==selectedNum ? 'pre' : 'nor') +'.png';
            $(this).attr("src", newSrc);
          });
        });
      $("#elapsedtimeinput>input").blur(function()
        {
          hour = parseInt($("#timeHour").val());
          minute = parseInt($("#timeMinute").val());
          second = parseInt($("#timeSecond").val());
          $("#runElapsedtime").val(hour * 3600 + minute * 60 + second);
        });
    });
  function checkUer(uid)
  {
    uid = $("#uid").val();
    if(Utils.isInt(uid) == false)
    {
      alert('请输入用户ID');
      return false;
    }
    $.ajax({url:"index.php?c=admin&a=checkVipUser&uid=" + uid,
            async:false,
            dataType:"json",
            error:function(){
                alert('未知错误');
                },
            success:function(data, status){
              turnData = eval(data);
              if(!Utils.isEmpty(turnData.message))
              {
                  $("#uid").val('');
                  alert(turnData.message);
              }
            }
        });
    return false;
  }
  function clearClickPoint(){
    $("#clickPoint").val('');
    $("#distance").val(0);
  }
</script>
<style type="text/css">
  /*li{list-style-type: none;margin: auto 5px;}*/
  .mapdiv{display: block;}
  .amap-container{display:block;height: 500px;}
  .amap-e, .amap-layer, .amap-layers, .amap-maps, .amap-tile, .amap-tile-container{position: relative;}
  img.amap-logo, .amap-copyright{display: none;}
  .amap-icon img{max-width: 280px;}
  /*#iCenter{display: none;}*/
</style>
<form enctype="multipart/form-data" class="form-horizontal" action="index.php?c=admin&a=addUserRunData&type=insert" method="post" name="runForm">
  <div class="control-group">
    <label class="control-label" for="inputTiltle">用户ID：</label>
    <div class="controls">
      <input type="text" name='uid' id="uid" placeholder="请输入用户ID" value="{$runData['uid']}" onblur="checkUer(this.value)">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputTiltle">跑步城市：</label>
    <div class="controls">
      <input type="text" name='runcity' placeholder="请填入跑步城市，精确到市（直辖市到区）" value="{$runData['city']}" style="width:300px;">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">绘制地图：</label>
    <div class="controls" >
      <div>
        省：
        <select id='province' style="width:100px"  onchange='search(this)'></select>
        市：
        <select id='city' style="width:100px"  onchange='search(this)'></select>
        区：
        <select id='district' style="width:100px" onchange='search(this)'></select>
      </div>
      <div style="margin:5px auto;">
        <btn onclick="clearClickPoint()" class="btn">重新选点</btn>
        <span>鼠标左键单击选点，右键单击结束选点。选点期间，用键盘方向键移动地图中心点，滚轮放大缩小地图</span>
      </div>
      <div class="mapdiv"><div id="iCenter"></div></div>
      <div class="mapdiv"><div id="iCenter2"></div></div>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc"></label>
    <div class="controls">
    <input type="hidden" name="clickPoint" id="clickPoint" readonly="readonly">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">跑步里程：</label>
    <div class="controls">
      <input type="text" id="distance" readonly="readonly" name="mileage" placeholder="请填入地图上显示的总里程" value="{$runData['mileage']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">跑步耗时：</label>
    <div class="controls" id="elapsedtimeinput">
      <input type="text" id="timeHour" value="0" style="width:50px;"><span>小时</span>
      <input type="text" id="timeMinute" value="0" style="width:50px;"><span>分钟</span>
      <input type="text" id="timeSecond" value="0" style="width:50px;"><span>秒</span>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc"></label>
    <div class="controls">
      <input type="text" name="elapsedtime" readonly="readonly" id="runElapsedtime" placeholder="{$runData['elapsedtime']}">
      <span>单位：秒</span>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">配速</label>
    <div class="controls">
      <textarea name="detail_speed" style="width:100%; min-height:100x;" placeholder="请输入每公里配速，配速之间用（‘|’）隔开"></textarea>
      <span>正常范围：2~99; 另外，配速个数请与跑步里程保证一致</span>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">消耗卡路里：</label>
    <div class="controls">
      <input type="text" name="calorie" placeholder="请输入消耗的卡路里" value="{$runData['calorie']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">目标类型：</label>
    <div class="controls">
      <select name="target_type">
        <option value="">请选择目标类型</option>
        {loop $targetType $k $type}
          <option value="{$k}" {if $runData['target_type'] == $k}selected="selected"{/if}>{$type}</option>
        {/loop}
      </select>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">目标完成度：</label>
    <div class="controls">
      <input type="text" name="target_rate" placeholder="请输入目标完成度" value="{$runData['target_rate']}">
      <span>例完成度为75%，输入0.75，保留两位小数点</span>
    </div>
  </div>
  <!-- {loop $runData['record_img'] $k $img}
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">跑步记录图片{$k}：</label>
    <div class="controls">
      <input type="file" name="record_img{$k}">
    </div>
  </div>
  {/loop} -->
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">跑步心情：</label>
    <div class="controls">
      <textarea name="run_mood" placeholder="请输入跑步心情" style="min-width:80%; min-height:100x;">{$runData['run_mood']}</textarea>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">跑步心情图标：</label>
    <div class="controls">
      <ul class="nav-pills" id="expressionUl">
      {loop $expression_corn $k $corn}
          <li><img {if $runData['expression_id'] != $k}src="static/backend/run_mood/{$corn}"{else}src="static/backend/run_mood/feeling_{$k}_pre.png"{/if} dataSrc="{$k}"></li>
      {/loop}
      </ul>
      <input type="hidden" name="expression_id" value="{$runData['expression_id']}" id="expressionId">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputaddtime">设置添加时间：</label>
    <div class="controls">
      <input type="text" name="updatetime" readonly="readonly" id="add_time_id" value="{eval echo date('Y-m-d H:i:s', $runData['updatetime'])}">
      <input name="add_time_btn" type="button" id="add_time_btn" onclick="return showCalendar('add_time_id', '%Y-%m-%d %H:%M', '24', false, 'add_time_btn');" value="选择" class="button" id="add_time_id"/>
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
        <button type="submit" class="btn">添加</button>
    </div>
  </div>
</form>
{template footer}